Skip to content

Create ">=0" assertion for unpromoted Span.Length#130326

Draft
EgorBo wants to merge 1 commit into
dotnet:mainfrom
EgorBo:preferred-bound-2
Draft

Create ">=0" assertion for unpromoted Span.Length#130326
EgorBo wants to merge 1 commit into
dotnet:mainfrom
EgorBo:preferred-bound-2

Conversation

@EgorBo

@EgorBo EgorBo commented Jul 8, 2026

Copy link
Copy Markdown
Member

A simple improvement, -30kb diff on win-x64

Copilot AI review requested due to automatic review settings July 8, 2026 01:22
@github-actions github-actions Bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jul 8, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adjusts JIT range/AssertionProp reasoning around Span/array length “checked-bound” values so the compiler can more consistently treat an unpromoted Span.Length indirection as non-negative and as the preferred bounds-check length value.

Changes:

  • In RangeCheck::ComputeRange, if the computed VN matches the caller-provided preferredBoundVN, represent the value as an exact symbolic range [bound, bound].
  • In optAssertionGen, generate an IND >= 0 assertion for TYP_INT indirections proven non-negative by IntegralRange (targeting unpromoted Span.Length).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/coreclr/jit/rangecheck.cpp Adds a preferred-bound fast path in range computation and simplifies GT_ARR_LENGTH handling.
src/coreclr/jit/assertionprop.cpp Adds IND >= 0 assertion generation for known-non-negative int indirections (notably unpromoted Span.Length).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants